package com.handu.luna.core.domain.goods;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.handu.luna.core.domain.BaseRepository;

public interface SKURepository  extends JpaRepository<SKU,Long>, BaseRepository<SKU>,JpaSpecificationExecutor<SKU>{

	@Query("select b from SKU b where b.goodsId =:goodsId order by id asc")
	List<SKU> findByGoodsId(@Param("goodsId") Long goodsId);
	
	@Query("from SKU b where b.goodsId =:goodsId and b.goodsAttributeValues =:goodsAttributeValues order by id asc")
	SKU findByGoodsIdAndAttributeValues(@Param("goodsId") Long goodsId,@Param("goodsAttributeValues") String goodsAttributeValues);
	
	@Query("from SKU b where b.sku_goodsSN =:sku_goodsSN")
	SKU findByGoodsSN(@Param("sku_goodsSN") String sku_goodsSN);
	
}
